import com.gzc.pojo.School;
import com.gzc.util.QueryListUtil;
import org.junit.Test;
import xin.xihc.utils.common.DateUtil;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class Test3 {

	public static void main(String[] args){
		School school = new School((long) 1, DateUtil.toDate("2011-11-11", "yyyy-MM-dd"));
		School school1 = new School((long) 2, DateUtil.toDate("2012-11-11", "yyyy-MM-dd"));
		School school2 = new School((long) 3, DateUtil.toDate("2013-11-11", "yyyy-MM-dd"));
		School school3 = new School((long) 4, DateUtil.toDate("2014-11-11", "yyyy-MM-dd"));
		School school4 = new School((long) 5, DateUtil.toDate("2015-11-11", "yyyy-MM-dd"));
		School school5 = new School((long) 6, DateUtil.toDate("2016-11-11", "yyyy-MM-dd"));

		ArrayList<School> schools = new ArrayList<>();
		schools.add(school);
		schools.add(school1);
		schools.add(school2);
		schools.add(school3);
		schools.add(school4);
		schools.add(school5);

		QueryListUtil instance = QueryListUtil.getInstance();

		instance.addGeaterThanCondition("createTime", DateUtil.toDate("2013-10-11", "yyyy-MM-dd"));
		instance.addLessThanCondition("createTime", DateUtil.toDate("2016-10-11", "yyyy-MM-dd"));

		List<School> query = instance.query(schools);

		System.out.println(query);
	}

	@Test
	public void testCompare(){
        School school2 = new School(3.0,new BigDecimal(3.0));
        School school = new School(	1.0,new BigDecimal(1.0));
        School school1 = new School(2.0,new BigDecimal(2.0));
		School school3 = new School(3.0,new BigDecimal(3.0));
		School school4 = new School(5.0,new BigDecimal(5.0));
		School school5 = new School(6.0,new BigDecimal(6.0));

		/*School school = new School((long) 1, DateUtil.toDate("2011-11-11", "yyyy-MM-dd"));
		School school1 = new School((long) 2, DateUtil.toDate("2012-11-11", "yyyy-MM-dd"));
		School school2 = new School((long) 3, DateUtil.toDate("2013-11-11", "yyyy-MM-dd"));
		School school3 = new School((long) 4, DateUtil.toDate("2014-11-11", "yyyy-MM-dd"));
		School school4 = new School((long) 5, DateUtil.toDate("2015-11-11", "yyyy-MM-dd"));
		School school5 = new School((long) 6, DateUtil.toDate("2016-11-11", "yyyy-MM-dd"));*/

		ArrayList<School> schools = new ArrayList<>();
		schools.add(school);
		schools.add(school1);
		schools.add(school2);
		schools.add(school3);
		schools.add(school4);
		schools.add(school5);

		/*int pageNumber =2;
		int pageSize = 10;

		ArrayList<School> schools1 = new ArrayList<>();

		int currIdx = (pageNumber > 1 ? (pageNumber -1) * pageSize : 0);
		for (int i = 0; i < pageSize && i < schools.size() - currIdx; i++) {
			School s = schools.get(currIdx + i);
			schools1.add(s);
		}
		System.out.println(schools1);*/

		Double i = 4D;

        ArrayList<Double> doubles = new ArrayList<>();
        doubles.add(1d);
        doubles.add(2d);

        List<School> schoolID = QueryListUtil.getInstance()
				.addLessThanCondition("bPrice", i)
                //.addInCondition("bPrice",doubles)
                //.addEqualCondition("price",1)
				//.limit(2,1)
                .orderBy("bPrice", QueryListUtil.OrderDirection.DESC)
				.query(schools);

		System.out.println(schoolID);


	}
}
